﻿using RuoVea.ExUtil.Validate;
using RuoVea.OmiApi.UserRoleMenu.Entitys;
using System.Collections;
using System.ComponentModel.DataAnnotations;

namespace RuoVea.OmiApi.UserRoleMenu.Service.Dto;
/// <summary>
/// 主键Id输入参数
/// </summary>
public class BaseIdInput
{
    /// <summary>
    /// 主键Id
    /// </summary>
    [Required(ErrorMessage = "Id不能为空")]
    [DataValidation(ValidationTypes.Numeric)]
    public virtual long Id { get; set; }
}
/// <summary>
/// 全局分页查询输入参数
/// </summary>
public class BasePageInput : PageParam
{
}
/// <summary>
/// 
/// </summary>
public class MenuInput
{
    /// <summary>
    /// 标题
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    /// 菜单类型（1目录 2菜单 3按钮）
    /// </summary>
    public MenuType? Type { get; set; }
}

/// <summary>
/// 
/// </summary>
public class AddMenuInput : SysMenu
{
    /// <summary>
    /// 名称
    /// </summary>
    [Required(ErrorMessage = "菜单名称不能为空")]
    public override string Title { get; set; }
}

/// <summary>
/// 
/// </summary>
public class UpdateMenuInput : AddMenuInput
{
}

/// <summary>
/// 
/// </summary>
public class DeleteMenuInput : BaseIdInput
{
}
/// <summary>
/// 
/// </summary>
public class TreeForGrantInput
{
    /// <summary>
    /// 应用分类（应用编码）
    /// </summary>
    public string Application { get; set; }
    /// <summary>
    /// 角色Id
    /// </summary>
    [Required, MaxLength(50)]
    public long RoleId { get; set; }
}

/// <summary>
/// 菜单树---授权、新增编辑时选择
/// </summary>
public class MenuTreeOutput : ITreeNode
{
    /// <summary>
    /// 主键
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 父Id
    /// </summary>
    public long ParentId { get; set; }

    /// <summary>
    /// 名称
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    /// 值
    /// </summary>
    public string Value => IntValue.ToString();
    /// <summary>
    /// 
    /// </summary>
    public long IntValue { get; set; }

    /// <summary>
    /// 子节点
    /// </summary>
    public List<MenuTreeOutput> Children { get; set; } = null;
    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    public long GetId()
    {
        return Id;
    }
    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    public long GetPid()
    {
        return ParentId;
    }

    /// <summary>
    /// 
    /// </summary>
    public void SetChildren(IList children)
    {
        Children = (List<MenuTreeOutput>)children;
    }
}
